﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpSphinx.Linguist.Dictionary
{
     public class Word
    {
         public static Word Unknown = new Word("<unk>", pros,false);


         static Pronunciation[] pros = { Pronunciation.Unknown };
        

         private string Spelling;
         private Pronunciation[] mPronunciations;
         private bool IsFiller;




         /// <summary>
         /// Creates a Word
         /// </summary>
         /// <param name="spelling">the spelling of this word</param>
         /// <param name="pronunciations">the pronunciations of this word</param>
         /// <param name="isFiller">true if the word is a filler word</param>
         public Word(String spelling, Pronunciation[] pronunciations,
                                       bool isFiller)
         {
             this.Spelling = spelling;
             this.mPronunciations = pronunciations;
             this.IsFiller = isFiller; 


         }

 
         /// <summary>
         ///  Returns the spelling of the word.
         /// </summary>
         /// <returns></returns>
         public string getSpelling()
         {
             return Spelling; 
         }



         /// <summary>
         /// Determines if this is a filler word
         /// </summary>
         /// <returns><code>true</code> if this word is a filler word, otherwise it returns <code>false</code></returns>
         public bool isFiller()
         {
             return IsFiller; 
         }

         /// <summary>
         /// Returns true if this word is a start of sentence word
         /// </summary>
         /// <returns></returns>
         public bool isSentenceStartWord()
         {
             return IDictionary.SENETECE_START_SPELLING.Equals(this.Spelling);
         }

         /// <summary>
         /// Returns true if this word is an end of sentence word
         /// </summary>
         /// <returns></returns>
         public bool isSentenceEndWord()
         {
             return IDictionary.SENTENCE_END_SPELLING.Equals(this.Spelling);
         }


         /// <summary>
         /// Retrieves the pronunciations of this word
         /// </summary>
         /// <param name="wordclassification">the classification of the word (typically part of speech classification) or null if all
         /// word classifications are acceptable. The word classification must be one of the set
         /// returned by <code>Dictionary.getPossibleWordClassifications</code>
         /// </param>
         /// <returns>the pronunciations of this word</returns>
         public Pronunciation[] getPronunciations
             (WordClassification wordclassification)
         {
             return mPronunciations; 
         }

         /// <summary>
         /// Retrieves the pronunciations of this word
         /// </summary>
         public Pronunciation[] Pronunciations
         {
             get
             {
                 return this.mPronunciations; 
             }
         }

         public Pronunciation getMostLikeyPronunciation()
         {
             float BestScore = float.NegativeInfinity;
             Pronunciation best = null; 
             foreach (Pronunciation pr in mPronunciations)
             {
                // if (pr.)
             }

             return best;
         }


         public override int GetHashCode()
         {
             return Spelling.GetHashCode();
         }


         public override bool Equals(object obj)
         {
             return obj is Word && Spelling.Equals(((Word)obj).Spelling);

         }

         public override string ToString()
         {
             return Spelling;
         }

    }
}
